package com.SpringBoot.brand.controller;


import com.SpringBoot.Util.Result;
import com.SpringBoot.brand.pojo.Brand;
import com.SpringBoot.brand.service.BrandService;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 品牌表 前端控制器
 * </p>
 *
 * @author bxk
 * @since 2025-09-15
 */
@Controller
@RestController
@RequestMapping("/brand")
public class BrandController {

    private final BrandService brandService;

    public BrandController(BrandService brandService) {
        this.brandService = brandService;
    }

    @PostMapping("/addBrand")
    public Result addBrand(@RequestBody Brand brand) {
        return brandService.addBrand(brand);
    }

    @PostMapping("/updateBrand")
    public Result updateBrand(@RequestBody Brand brand) {
        return brandService.updateBrand(brand);
    }

    @PostMapping("/deleteById")
    public Result deleteById(@RequestParam Integer brandId,
                             @RequestParam Integer status){
        return brandService.deleteById(brandId,status);
    }

    @GetMapping("/selectByNameLike")
    public Result selectByNameLike(@RequestParam String name){
        return brandService.selectByNameLike(name);
    }

    @GetMapping("/selectBrandName")
    public Result selectBrandName(){return brandService.selectBrandName();}

    @GetMapping("/selectAllBrand")
    public Result selectAllBrand(@RequestParam Integer pageNum, @RequestParam Integer pageSize){
        return brandService.selectAllBrand(pageNum,pageSize);
    }

}
